<!-- 整改会议 => 研究整改工作 -->
<template>
  <a-spin tip="正在导出,请等待..." size="large" :spinning="loading" style="font-size: 18px">
  <div class="lanjian-content pdd">
    <div class="tableOperator">
      <div class="btn-box">
        <a-button type='primary' class='ClassA m-r-8' @click="add" title='新增'>
          <span class='icon iconfont'>&#xe675;</span>
        </a-button>
        <a-button type='primary' class='ClassA' title='导出提报' @click="exportFile">
          <span class='icon iconfont'>&#xe6bf;</span>
        </a-button>
      </div>
      <div class="input-box">
        <a-input v-model="queryParam.theme" class='m-r-8' placeholder="会议主题" />
        <a-select placeholder="请选择会议类型" class='m-r-8' v-model="queryParam.meetingType" :allowClear="true">
          <a-select-option
            :key="item.id"
            v-for="item in options"
            :value="item.id"
          >{{ item.value }}
          </a-select-option>
        </a-select>
        <a-range-picker v-model:value="meetinga2e" class='m-r-8' :format="dateFormatList" />
        <a-button type='primary' class='m-r-8 ClassA' @click='search' title='搜索'>
          <span class='icon iconfont'>&#xe666;</span>
        </a-button>
        <a-button class='resBtn ClassA' @click='loadtable' title='重置'>
          <span class='icon iconfont'>&#xe672;</span>
        </a-button>
      </div>
    </div>
    <a-table
      :Key='tablekey'
      class="table-box"
      bordered
      :columns="columns"
      :data-source="dataSource"
      :pagination="pagination"
      @change="tablePaginationChange"
      rowKey="id"
    >
      <span
        slot="meetingTime"
        slot-scope="text, record">
        {{ record.startMeetingTime }} - {{ record.endMeetingTime }}
      </span>
      <span
        slot="action"
        slot-scope="record"
        class="actionIcons">
        <span @click="see(record)">
                            <i class='icon iconfont' title='查看'>&#xe67b;</i>
                        </span>
        	<span @click="edit(record)" v-show="record.f_status!='5'&&record.f_status!='2'">
                            <i class='icon iconfont' title='编辑'>&#xe676;</i>
                        </span>

          	<span class='remove' v-show="record.f_status!='5'&&record.f_status!='2'" @click="handleOkdelopen(record)">
                            <i class='icon iconfont' title='删除'>&#xe673;</i>
                        </span>
      </span>
    </a-table>
    <a-modal
      centered
      :key="editedKey"
      title="整改会议"
      :visible="seeVisible"
      :confirm-loading="confirmLoading"
      @cancel="handleCancel"
      :width="1200"
    >
      <!-- <a-tabs v-model="activeKey">
        <a-tab-pane key="1" tab="会议信息"> -->

      <div class="lanjian-content pdd tab-h">
        <a-tabs v-model="activeKey" type='editable-card' border="false" hide-add @change="chs"
                foldbtn="false">
          <a-tab-pane key="1" tab="整改会议" :closable="false">
            <div class="bbox">
              <table  class="detailsBox">
                <tr class="detailstag">
                  <td class="title">
                    会议主题
                  </td>
                  <td class="content">
                    {{ ruleForm.theme}}
                  </td>
                </tr>
                <tr class="detailstag">
                  <td class="title">
                    会议日期
                  </td>
                  <td class="content">
                    {{ ruleForm.dateOfMeeting}}
                  </td>
                </tr>
                <tr class="detailstag">
                  <td class="title">
                    会议时间
                  </td>
                  <td class="content">
                    {{ ruleForm.startMeetingTime }} - {{ ruleForm.endMeetingTime }}
                  </td>
                </tr>
                <tr class="detailstag">
                  <td class="title">
                    主持人
                  </td>
                  <td class="content">
                    {{ ruleForm.host}}
                  </td>
                </tr>
                <tr class="detailstag">
                  <td class="title">
                    会议类型
                  </td>
                  <td class="content">
                    {{ this.getMettingType(ruleForm.meetingType)}}
                  </td>
                </tr>
                <tr class="detailstag">
                  <td class="title">
                    参会人员
                  </td>
                  <td class="content">
                    {{ ruleForm.participants}}
                  </td>
                </tr>
                <tr class="detailstag">
                  <td class="title">
                    会议提纲
                  </td>
                  <td class="content">
                    {{ ruleForm.meetingSummary}}
                  </td>
                </tr>
                <tr class="detailstag">
                  <td class="title">
                    会议材料
                  </td>
                  <td class="content">
                    <div v-for="item in ruleForm.fileList" :key="item.id">
                      <a @click="downLoadFunction(item.url,item.name)"><span>{{ item.name }}</span></a>
                    </div>
                  </td>
                </tr>
              </table>
            </div>

                <!--            <a-form-model-item label="会议主题" class="formtab" :labelCol="labelCol1" :wrapperCol="wrapperCol1"
                                               prop="theme">
                              <span>{{ ruleForm.theme }}</span>
                            </a-form-model-item>
                            <a-form-model-item label="会议日期" class="formtab" prop="dateOfMeeting">
                              <span>{{ ruleForm.dateOfMeeting }}</span>
                            </a-form-model-item>
                            <a-form-model-item label="会议时间" class="formtab" prop="meetingTime">
                              <span>{{ ruleForm.startMeetingTime }} - {{ ruleForm.endMeetingTime }}</span>
                            </a-form-model-item>
                            <a-form-model-item label="主持人" class="formtab" prop="host">
                              <span>{{ ruleForm.host }}</span>
                            </a-form-model-item>
                            <a-form-model-item label="会议类型" class="formtab" prop="meetingType">
                              <span>{{ getMettingType(ruleForm.meetingType) }}</span>
                            </a-form-model-item>
                            <a-form-model-item label="参会人员" class="formtab" :labelCol="labelCol1" :wrapperCol="wrapperCol1"
                                               prop="participants">
                              <span>{{ ruleForm.participants }}</span>
                            </a-form-model-item>
                            <a-form-model-item label="会议提纲" class="formtab" :labelCol="labelCol1" :wrapperCol="wrapperCol1"
                                               prop="meetingSummary">
                              <span>{{ ruleForm.meetingSummary }}</span>
                            </a-form-model-item>
                            <a-form-model-item label="会议材料" class="formtab" :labelCol="labelCol1" :wrapperCol="wrapperCol1">
                              <div v-for="item in ruleForm.fileList" :key="item.id">
                                <span>{{ item.name }}</span>
                              </div>
                            </a-form-model-item>-->
          </a-tab-pane>
          <a-tab-pane key="4" tab="审批历史" :closable="false">
            <ApprovalHistory ref="mhis"></ApprovalHistory>
          </a-tab-pane>
        </a-tabs>

      </div>
      <!-- </a-tab-pane> -->
      <!-- <a-tab-pane key="2" tab="提交审批记录">
        <div class="search-box">
          <div class="input-box">
            <a-range-picker v-model="queryParam1.attr" @change="onChange" />
            <a-button type="primary" @click="search1">
              搜索
            </a-button>
            <a-button @click="loadtable1">
              重置
            </a-button>
          </div>
        </div>
        <a-table
          class="table-box"
          :columns="columns1"
          :data-source="dataSource1"
          :pagination="false"
          rowKey="id"
          style="height: 400px"
        >
        </a-table>
      </a-tab-pane> -->
      <!-- </a-tabs> -->
      <template slot="footer">
        <a-button @click="handleCancel">取消</a-button>
      </template>
    </a-modal>
    <a-modal
      centered
      :key="modkey1"
      :title="visibleTitle"
      v-model:visible="editVisible"
      :confirm-loading="confirmLoading"
      @ok="handleOk"
      @cancel="handleCancel"
      cancelText="取消"
      okText="确认"
      :z-index="1000"
      width="70%"
    >
      <div class="lanjian-content">
        <div class='singleRow'>
          <a-form-model
            ref="ruleForm1"
            :labelCol="labelCol"
            :wrapperCol="wrapperCol"
            :rules="rules"
            :model="ruleForm1"
            class="formbox"
          >
            <a-form-model-item label="会议主题" class="formtabMax"
                               prop="theme">
              <a-input placeholder="会议主题" v-model.trim="ruleForm1.theme" :maxLength=50 />
            </a-form-model-item>
            <a-row style="width: 100%" >
              <a-col :span="12">
                <a-form-model-item label="会议日期" class="formtab" prop="dateOfMeeting">
                  <a-date-picker class="w260" @change="onChange1" v-model="ruleForm1.dateOfMeeting" />
                </a-form-model-item>
              </a-col>
              <a-col
                :span="12">
                <a-form-model-item label="会议时间" class="formtab" prop="meetingTime">
                  <a-time-picker format="HH:mm" class="picker" v-model="ruleForm1.startMeetingTime"
                                 @change="startMeetingTimeChange" />
                  至
                  <a-time-picker format="HH:mm" class="picker" v-model="ruleForm1.endMeetingTime"
                                 @change="ednMeetingTimeChange" />
                </a-form-model-item>
              </a-col>
            </a-row>


            <a-form-model-item label="主持人" class="formtabMax" prop="host">
              <a-input placeholder="主持人" v-model.trim="ruleForm1.host" maxLength="50" :maxLength=50 />
            </a-form-model-item>
            <a-form-model-item label="会议类型" class="formtab" prop="meetingType">
              <a-select placeholder="请选择会议类型" v-model="ruleForm1.meetingType" :allowClear="true">
                <a-select-option
                  :key="item.id"
                  v-for="item in options"
                  :value="item.id"
                >{{ item.value }}
                </a-select-option>

              </a-select>
            </a-form-model-item>
            <a-form-model-item label="参会人员" class="formtab"
                               prop="participants">
              <a-input placeholder="参会人员" v-model.trim="ruleForm1.participants" maxLength="50" :maxLength=50 />
            </a-form-model-item>
            <a-form-model-item label="会议提纲" class="formtab"
                               prop="meetingSummary">
              <a-input placeholder="会议提纲" v-model.trim="ruleForm1.meetingSummary" type="textarea" :maxLength=500 />
            </a-form-model-item>
            <a-form-model-item label="jlid" v-if="false"
                               >
              <a-input  v-model="ruleForm1.jlid" type="textarea" :maxLength=500 />
            </a-form-model-item>
            <a-form-model-item label="会议材料" class="formtab" v-model="ruleForm1.id"
            >
              <a-upload
                :key="ruleForm1.id"
                :multiple="true"
                :file-list="ruleForm1.fileList"
                :customRequest="customUpload"
                :before-upload="beforeFileUpload"
                :showUploadList="true"
                :remove="filerm"
                @preview="downlocal"
                accept=".doc,.docx,.xls,.xlsx,.jpg,.jpeg,.png,.pdf,.txt"
              >
                <a-button class='ClassA'>
                  <span class='icon iconfont'>&#xe677;</span>
                </a-button>
                <a-tooltip>
                  <template slot="title">
                    仅支持上传doc、docx、xls、xlsx、jpg、jpeg、png、pdf、txt格式的文件,文件大小不超过200M。
                  </template>
                  <a-icon type="question-circle" style="margin-left: 15px;color: orange;line-height: 36px" />
                </a-tooltip>
              </a-upload>
            </a-form-model-item>
          </a-form-model>
        </div>
      </div>
      <template slot="footer">
        <a-button @click="handleOk" type="primary">保存</a-button>
        <a-button @click="handleCancel">取消</a-button>
      </template>
    </a-modal>

    <a-modal v-model:visible="exvisible" title="删除确认"  centered >
      <p></p>  <p><span style="color: #ff0000; margin:30px ">确定要删除此数据吗</span></p>  <p></p>
      <template slot="footer">
        <a-button @click="handleOkdel" type="primary">确定</a-button>
        <a-button @click="handleCancelex">取消</a-button>
      </template>
    </a-modal>

  </div>
  </a-spin>
</template>

<script>
import {
  getRectificationMeeting, addRectificationMeeting, delRectificationMeeting, getuploadFileInfo,
} from '@/utils/JsonTools';
import {
   mkdir, exportModule, streamToBuffer,
} from '@/utils/fileUtils';
import {
  getcurDate,
  getSystemDir
} from '@/utils/common';
import {
  downLoadFunction,
  formatDate,
  getNowMilliSecond, getStatusType, getTimeBetween
} from '@/utils/common';
import moment from 'moment';
import fs from "fs";
import ApprovalHistory from './ApprovalHistory.vue';

export default {
  name: 'RectificationMeeting',
  components: { ApprovalHistory },
  data() {
    return {
      loading: false,
      exvisible:false,
      open: false,
      meetinga2e:[],
      dateFormatList:'YYYY/MM/DD',
      options: [{
        id: 2,
        value: '党委（组、支）会议',
      }, {
        id: 1,
        value: '民主生活会',
      }],
      tablekey: 1,
      modkey1: 1,
      modkey2: 2,
      activeKey: '1',
      // 列
      columns: [
        {
          title: '序号',
          width: 70,
          align: 'center',
          customRender: (text, record, index) => `${index + 1}`,
        },
        {
          title: '会议主题',
          dataIndex: 'theme',
          key: 'theme',
          align: 'center',
          width: 160,
          ellipsis: true,
        },
        {
          title: '会议类型',
          dataIndex: 'meetingType',
          key: 'meetingType',
          width: 160,
          align: 'center',
          ellipsis: true,
          customRender: (text, record, index) => {
            // eslint-disable-next-line no-empty,no-undef
            return this.getMettingType(record.meetingType);
          },
        },
        {
          title: '会议日期',
          dataIndex: 'dateOfMeeting',
          key: 'dateOfMeeting',
          width: 160,
          align: 'center',
          ellipsis: true,
        },
        {
          title: '会议时间',
          dataIndex: 'meetingTime',
          align: 'center',
          ellipsis: true,
          width: 160,
          scopedSlots: { customRender: 'meetingTime' },
        },
        {
          title: '主持人',
          dataIndex: 'host',
          key: 'host',
          width: 160,
          align: 'center',
          ellipsis: true,
        },
        {
          title: '审批状态',
          dataIndex: 'f_status',
          key: 'f_status',
          width: 160,
          align: 'center',
          ellipsis: true,
          customRender: (text, record, index) => {
            // eslint-disable-next-line no-empty,no-undef
            return getStatusType(record.f_status);
          },
        },
        // {
        //   title: '处理状态',
        //   dataIndex: 'clstatus',
        //   key: 'clstatus',
        //   align: 'center',
        //   ellipsis: true
        // },
        {
          title: '操作',
          key: 'operation',
          align: 'center',
          width: 170,
          scopedSlots: { customRender: 'action' },
        },
      ],
      dataSource: [],
      queryParam: {
        meetingType: undefined,
        theme: undefined,
        spstatus: undefined,
      },
      queryParam1: {
        attr: [],
      },
      // 分页参数
      pagination: {
        current: 1,
        // defaultCurrent: 1,
        total: 0, // 总数
        showSizeChanger: true,
        // 是否可以快速跳转至某页
        showQuickJumper: true,
        pageSizeOptions: ['10', '20', '40', '80', '100'],
        // showTotal: total => '共 ${total} 条', // 分页中显示总的数据
        // hideOnSinglePage: true, // 只有一页时是否隐藏分页器
        pageSize: 10, // 每页条数，所有页设置统一的条数
      },
      // 选中值
      ruleForm: {},
      ruleForm1: {
        fileList: [],
      },
      fileList: [],
      editedKey:"",
      defaultfileList: [],
      // 表单标题内容宽度设置
      labelCol: { span: 24 },
      wrapperCol: { span: 24 },
      labelCol1: { span: 3 },
      wrapperCol1: { span: 21 },
      // 表单规则
      rules: {
        theme: [{ required: true, message: '请输入会议主题', trigger: 'blur' }],
        dateOfMeeting: [{ required: true, message: '请输入会议日期', trigger: 'change' }],
        meetingTime: [{ required: false, message: '请输入会议时间', trigger: 'change' }],
        host: [{ required: false, message: '请输入主持人', trigger: 'blur' }],
        meetingType: [{ required: true, message: '请输入会议类型', trigger: 'change' }],
        participants: [{ required: false, message: '请输入参会人员', trigger: 'blur' }],
        meetingSummary: [{ required: false, message: '请输入会议摘要', trigger: 'blur' }],
      },
      // 弹框显示
      seeVisible: false,
      editVisible: false,
      // 弹框标题
      visibleTitle: '',
      // 弹框加载状态
      confirmLoading: false,
      // 列
      columns1: [
        {
          title: '序号',
          width: 70,
          align: 'center',
          customRender: (text, record, index) => `${index + 1}`,
        },
        {
          title: '发送时间',
          dataIndex: 'theme',
          key: 'theme',
          align: 'center',
          ellipsis: true,
        },
        {
          title: '审核单位',
          dataIndex: 'meetingType',
          key: 'meetingType',
          align: 'center',
          ellipsis: true,
        },
        {
          title: '操作人',
          dataIndex: 'dateOfMeeting',
          key: 'dateOfMeeting',
          align: 'center',
          ellipsis: true,
        },
        {
          title: '审批意见',
          dataIndex: 'host',
          key: 'host',
          align: 'center',
          ellipsis: true,
        },
        {
          title: '审批说明',
          dataIndex: 'spstatus',
          key: 'spstatus',
          align: 'center',
          ellipsis: true,
        },
        {
          title: '说明材料',
          dataIndex: 'clstatus',
          key: 'clstatus',
          align: 'center',
          ellipsis: true,
        },
        {
          title: '审批时间',
          dataIndex: 'clstatus',
          key: 'operation',
          align: 'center',
          ellipsis: true,
        },
      ],
      dataSource1: [],
      record:{}
    };
  },
  created() {
  },
  mounted() {
    this.loadtable();
    //this.meetinga2e=[moment(new Date(), this.dateFormatList),moment(new Date(), this.dateFormatList)];
  },
  methods: {
    downLoadFunction,
    handleOkdel(){
      this.dele(this.record)
    },
    handleOkdelopen(record){
      this.record=record
      this.exvisible=true
    },
    filerm(file) {
      console.log('rm---' + JSON.stringify(file));
      console.log('LLS---' + JSON.stringify(this.ruleForm1.fileList));
      this.ruleForm1.fileList.forEach(sitem => {
        if (sitem.uid === file.uid) {
          let index = this.ruleForm1.fileList.indexOf(sitem);
          if (index > -1) {
            this.ruleForm1.fileList.splice(index, 1);
          }
        }
      });
    },
    getMettingType(type) {
      if (type === 1) {
        return '民生生活会';
      } else if (type === 2) {
        return '党委（组、支）会议';
      } else {
        return '其他';
      }
    },
    mounted() {
      this.loadtable()
    },
    moment,
    // 搜索时间选择器
    onChange(date, dateString) {
      this.queryParam1.attr = [...dateString];
    },
    tablePaginationChange(pagination) {
      // 重新设置当前页
      this.pagination.current = pagination.current;
      this.pagination.pageSize = pagination.pageSize;
    },
    // 查询研究整改工作
    loadtable() {
      this.queryParam.meetingType = undefined;
      this.queryParam.theme = undefined;
      this.queryParam.spstatus = undefined;
      this.meetinga2e=[]
      getRectificationMeeting().then(res => {
        res.sort((a, b) => {
          const date1=new Date(a.uploadTime).getTime()
          const date2=new Date(b.uploadTime).getTime()
          if(date1<date2){
            return 1
          }else{
            return -1
          }
        })
        this.dataSource = [...res];
      });
      this.$nextTick(() => {
        this.tablekey = this.getRandomId();
        this.modkey1 = this.getRandomId();
        this.modkey2 = this.getRandomId();
      });
    },
    getRandomId() {
      return Math.floor((Math.random() * 100000000) + 1);
    },
    // 搜索研究整改工作
    search() {
      getRectificationMeeting().then(res => {
        console.log(res);
        // eslint-disable-next-line no-undef
        console.log(this.queryParam);
        let arr = [];
        let a, b, c;
        if (this.queryParam.meetingType === undefined) {
          a = "";
        } else {
          a = this.queryParam.meetingType+"";
        }
        if (this.queryParam.theme === undefined) {
          b = '';
        } else {
          b = this.queryParam.theme;
        }
        if (this.meetinga2e === undefined||this.meetinga2e.length==0) {
          c = [];
        } else {
          c = this.meetinga2e;
        }

        res.forEach(element => {
          console.log();
          // eslint-disable-next-line eqeqeq
          if(c.length>0){
            console.log("m2e---",element.dateOfMeeting)
            let datel = formatDate(new Date(Date.parse(element.dateOfMeeting)), 'Y-M-D')
            //if (this.queryParam.attr.length > 0 && this.queryParam.attr[0] != '') {
            let  dates = formatDate(new Date(Date.parse(c[0])), 'Y-M-D')
            let  datee = formatDate(new Date(Date.parse(c[1])), 'Y-M-D')
            //}
            if(dates <= datel && datel <= datee){
              if(element.theme.indexOf(b) > -1 && (element.meetingType+"").indexOf(a)> -1 ){
                arr.push(element);
              }else{
                arr.push(element);
              }
            }
          }else{
            if(element.theme.indexOf(b) > -1 && (element.meetingType+"").indexOf(a) > -1){
              arr.push(element);
            }
          }
          // if (a === -1) {
          //   if ((element.theme).indexOf(b) > -1) {
          //     arr.push(element);
          //   }
          // } else {
          //   if(new Date(this.meetinga2e[0]._d)>=new Date(element.dateOfMeeting)){
          //     console.log("t--",true)
          //   }
          //   //arr.push(element);
          //   if (element.meetingType === a && (element.theme).indexOf(b) > -1&&(this.meetinga2e.length>0?new Date(this.meetinga2e[0]._d)<=new Date(element.dateOfMeeting)&&new Date(element.dateOfMeeting)<=new Date(this.meetinga2e[0]._d):true)) {
          //     arr.push(element);
          //    }
          //  }
          console.log(arr);
        });
        res.sort((a, b) => {
          const date1=new Date(a.uploadTime).getTime()
          const date2=new Date(b.uploadTime).getTime()
          if(date1<date2){
            return 1
          }else{
            return -1
          }
        })
        this.dataSource = [...arr];
      });
    },
    add() {
      this.tablekey = this.getRandomId();
      this.modkey1 = this.getRandomId();
      this.fileList=[]
      this.ruleForm={}
      this.ruleForm1 = {fileList:[]};
      this.ruleForm1.version=getNowMilliSecond()
      //this.$refs.ruleForm1.clearValidate()
      this.editVisible = true;
      this.visibleTitle = '新增整改会议';
      console.log("ad====",this.$refs)
    },
    exportFile() {
      this.loading=true
      let foldid=getNowMilliSecond()
      let dir=getSystemDir()
      console.log("pp--s--",dir)
      mkdir(dir)
      mkdir(dir+"\\"+foldid)
      exportModule(1,dir+"\\"+foldid).then(res=>{
        this.loading=false
        if(res==0){
          this.$message.error('导出失败')
          return
        }
        if(res==1){
          this.$message.success('导出成功')
          this.loadtable()
          return
        }
        this.$message.warn('未完成数据填报，无法导出提报')

      })

    },
    edit(record) {
       this.modkey1 = this.getRandomId();
      this.editVisible = true;
      // this.$refs.ruleForm1.clearValidate()
      // console.log(record);
      this.ruleForm1 = { ...record };
      this.ruleForm1.meetingTime = [record.startMeetingTime, record.endMeetingTime];
      // eslint-disable-next-line eqeqeq
      this.ruleForm1.startMeetingTime = this.ruleForm1.startMeetingTime ? moment(record.startMeetingTime, 'HH:mm') : null;
      this.ruleForm1.endMeetingTime = this.ruleForm1.endMeetingTime ? moment(record.endMeetingTime, 'HH:mm') : null;
      this.ruleForm1.meetingType = record.meetingType;
      this.ruleForm1.fileList = record.fileList;
      this.fileList=record.fileList
      this.visibleTitle = '编辑';
    },
    see(record) {
      this.$nextTick(s => {
        this.activeKey=1+""
        this.ruleForm = record
        this.seeVisible = true;
        this.editedKey=getNowMilliSecond()
      });
    },
    handleCancelex(){
      this.exvisible=false
    },
    dele(record) {
      delRectificationMeeting(record).then(res => {
        // eslint-disable-next-line eqeqeq
        if (res == 1) {
          this.loadtable();
          this.$message.success('删除成功');
          this.exvisible=false
        } else {
          this.$message.error('删除失败');
        }
      });
    },
    // 会议日期
    onChange1(date, dateString) {
      this.ruleForm1.dateOfMeeting = dateString;
    },
    chs(){
      this.$nextTick(s => {
        this.$refs.mhis.getmHIS(this.ruleForm)
      })

    },
    // 开始会议时间
    startMeetingTimeChange(date, dateString) {
      if (this.ruleForm1.startMeetingTime && this.ruleForm1.endMeetingTime) {
        this.ruleForm1.meetingTime = [moment(this.ruleForm1.startMeetingTime).format('HH:mm'), moment(this.ruleForm1.endMeetingTime).format('HH:mm')];
      } else {
        this.ruleForm1.meetingTime = undefined;
      }
    },
    // 结束会议时间
    ednMeetingTimeChange(date, dateString) {
      if (this.ruleForm1.startMeetingTime && this.ruleForm1.endMeetingTime) {
        this.ruleForm1.meetingTime = [moment(this.ruleForm1.startMeetingTime).format('HH:mm'), moment(this.ruleForm1.endMeetingTime).format('HH:mm')];
      } else {
        this.ruleForm1.meetingTime = undefined;
      }
    },
    // 上传验证
    beforeFileUpload(file) {
      if (file.name.substring(0, file.name.indexOf('.')).length > 200) {
        this.$message.error('上传文件名字不得超过200字');
        return false;
      }
      let isLt2M = file.size / 1024 / 1024;
      if (isLt2M > 200) {
        this.$message.error('只允许上传200M以下的文件');
        return false;
      }
      let fileExt = file.name.slice(file.name.lastIndexOf('.') + 1);
      let fileTypeArr = ['doc', 'docx', 'xls', 'xlsx', 'jpg', 'jpeg', 'png', 'pdf', 'txt', 'zip', 'rar'];
      if (fileTypeArr.indexOf(fileExt) === -1) {
        this.$message.error('非法的文件类型');
        return false;
      }
      return true;
    },
    customUpload(file) {
      // beforeFileUpload()返回为true，才会触发这个方法；
      this.handleUpload(file);
    },
    // 构造formData
    handleUpload(file) {
      console.log(file.file);
      getuploadFileInfo(file.file).then(res => {
        // eslint-disable-next-line no-unused-expressions
        this.ruleForm1.fileList === undefined||  this.ruleForm1.fileList.length===0? this.ruleForm1.fileList = [] : this.ruleForm1.fileList;
        // eslint-disable-next-line array-callback-return,eqeqeq,no-undef
        res.zgfid=getNowMilliSecond()+""
        this.ruleForm1.fileList.push(res);
        file.onSuccess(res);
        // console.log(file.response)
      });
    },
    // 上传
    async imagerAdd(formData) {

    },
    handleChange(FileInfo) {
      console.log(this.ruleForm1.fileList);
      console.log(FileInfo);
      // eslint-disable-next-line eqeqeq,no-unused-expressions
      // eslint-disable-next-line eqeqeq
      if (FileInfo.file.status == 'removed') {
        // eslint-disable-next-line eqeqeq
        this.ruleForm1.fileList.forEach(sitem => {
          if (sitem.uid === FileInfo.file.uid) {
            let index = this.ruleForm1.fileList.indexOf(sitem);
            if (index > -1) {
              this.ruleForm1.fileList.splice(index, 1);
            }
          }
        });
        // this.ruleForm1.fileList = this.ruleForm1.fileList.filter(item => item.uid == FileInfo.response.uid)
      }
      // FileInfo.fileList.forEach(m => {
      //   // eslint-disable-next-line eqeqeq
      //   if (m != undefined && m != null) {
      //     this.ruleForm1.fileList.push(m.response)
      //   }
      // })
    },
    handleOk (e) {
      this.$refs.ruleForm1.validate(valid => {
        // eslint-disable-next-line eqeqeq
        if (valid) {
          if (this.ruleForm1.meetingTime != undefined) {
            if (this.ruleForm1.meetingTime[0] > this.ruleForm1.meetingTime[1]) {
              this.$message.error('会议开始时间不能大于会议结束时间')
              return false
            }
          }
          this.ruleForm1.version=getNowMilliSecond()
          addRectificationMeeting(this.ruleForm1).then(res => {
            // eslint-disable-next-line eqeqeq
            if (res == 1) {
              this.$nextTick(s => {
                this.fileList = []
                this.ruleForm1.fileList = []
                this.ruleForm={}
              })
              this.$message.success('操作成功')
              this.editVisible = false
              this.loadtable()
            } else {
              this.$message.error('操作失败')
            }
          })
        }
      })
    },
    handleCancel(e) {
      this.seeVisible = false
      this.editVisible = false
      this.loadtable()
    },
    // 查询研究整改工作审批记录
    loadtable1() {
      this.dataSource1 = [...JSON.parse(this.ruleForm.approvalrecord)];
    },
    downlocal(file){
      let fileb = fs.createReadStream(file.url)
      streamToBuffer(fileb).then(res => {
        let data = res
        let contents = new Uint8Array(data.length)
        for (let i = 0; i < data.length; i++) {
          contents[i] = data[i]
        }
        saveAs.saveAs(new Blob([contents], { type: 'application/zip' }), file.name)
      })
    },
     showDeleteConfirm (record) {
      let that=this
      Modal.confirm({
        title: '数据删除?',
        content: '确定要删除此条数据吗？',
        okText: '确定',
        okType: 'danger',
        cancelText: '取消',
        onOk() {
          that.dele(record)
          console.log('OK');
        },
        onCancel() {
          console.log('Cancel');
        },
      });
    }
  },
};
</script>
<style lang="less" scoped>
.tableHiddle {
  display: none;
}
/deep/.ant-tabs-content{
}
.bbox{
  height: 420px;
  overflow: auto
}
.tab-h{
  height: 500px;
}
.picker {
  width: 180px;
}

.w260 {
  width: 260px !important;
}
</style>
